import javax.swing.JPanel;
import java.awt.CardLayout;
import java.awt.Dimension;
import javax.swing.JLabel;
import java.awt.Color;
import java.awt.Font;
import javax.swing.BoxLayout;
import javax.swing.ButtonGroup;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.JRadioButton;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Random;
import javax.swing.SwingConstants;
import javax.swing.JComboBox;
import javax.swing.JProgressBar;
/**
 * Main panel that represents the GUI of the game
 * 
 * @author samkim
 *
 */

@SuppressWarnings("serial")
public class MainCardPanel extends JPanel implements ActionListener {
	private GameSystem system;
	private JTextField leaderName;
	private JTextField Member1Name;
	private JTextField Member2Name;
	private JTextField Member3Name;
	private JTextField Member4Name;
	private JLabel lblMap,lblDistance,lblFoodSuply,lblWaterSupply,startMessage, DayLeft, homeMember1Health, homeMember2Health, homeMember3Health, homeMember4Health, homeCurrentLabel;
	private JButton startNewGameButton, leadersInitContinueButton, membersInitContinueButton, gameStartStartButton;
	private JButton homeMarchButton, toShopButton, shopBackButton, shopBuyButton, victoryCreditsButton, skipButton, diedOkayButton;
	private CardLayout cards;
	private JPanel leaderInit, membersInit, gameStart, homePage, shopPage;
	private ButtonGroup occupationGroup;
	private JRadioButton soldierButton, medicButton, rangerButton, cookButton;
	private JTextField shopFoodText;
	private JTextField shopWaterText;
	private JTextField shopAmmunitionText;
	private JComboBox rationCB, paceCB, shopWeaponCB, shopItemCB;
	private JPanel victoryPanel;
	private JPanel creditsPanel;
	private JPanel riverPanel;
	private JLabel lblNewLabel_10;
	private JLabel lblNewLabel_11;
	private JLabel lblThanksForPlaying;
	private JProgressBar healthBar0, healthBar1, healthBar2, healthBar3; 
	private JButton startContinueGameButton;
	private JButton homeSaveGameButton, btnPlayAgain;
	private JPanel panel;
	private JLabel saveTitle;
	private JLabel lblNewLabel_8;
	private JButton cross, boat, around;
	private JPanel diedPanel;
	private JLabel diedMessageText;
	private JPanel endPanel;
	private JLabel lblEverybodyIs, shopMoneyLabel, shopWeaponLabel;
	private JPanel minigamePanel;
	private JLabel lblAmmo;
	int width=945, height=675;
	private JLabel shopFoodLabel;
	private JLabel shopWaterLabel;
	private JLabel shopAmmunitionLabel;
	private JLabel shopWeightLabel;
	private JLabel shopItemsLabel;
	private JLabel lblNewLabel_13;
	private JLabel lblBinoculars;
	private JPanel eventPanel;
	private JLabel lblBackground_1;


	/**
	 * Create the panel.
	 */
	public MainCardPanel(GameSystem system) {
		
		this.system = system;
		setPreferredSize(new Dimension(width,height));
		cards = new CardLayout();
		setLayout(cards);
		
		//add(minigamePanel = new JPanel(),"minigamePanel");
		//minigamePanel.setLayout(null);
		//minigamePanel.add(new MgBoard(width, height, system.getParty()),"bb");
		minigamePanel = new JPanel();
		add(minigamePanel, "minigamePanel");
		minigamePanel.setLayout(null);
		//showMinigame();
		
		JPanel startPage = new JPanel();
		startPage.setBackground(Color.LIGHT_GRAY);
		add(startPage, "startPage");
		startPage.setLayout(null);
		cards.show(this, "startPage");
		
		JLabel lblBehindEnemyLines = new JLabel("BEHIND ENEMY LINES");
		lblBehindEnemyLines.setForeground(Color.PINK);
		lblBehindEnemyLines.setFont(new Font("Dialog", Font.PLAIN, 36));
		lblBehindEnemyLines.setBounds(280, 75, 450, 100);
		startPage.add(lblBehindEnemyLines);
		
		startNewGameButton = new JButton("NEW GAME");
		startNewGameButton.setBounds(180, 600, 100, 40);
		startPage.add(startNewGameButton);
		
		skipButton = new JButton("Skip");
		skipButton.setBounds(660, 600, 100, 40);
		skipButton.addActionListener(this);
		
		startPage.add(skipButton);
		
		startContinueGameButton = new JButton("CONTINUE");
		startContinueGameButton.setBounds(440, 600, 100, 40);
		startPage.add(startContinueGameButton);
		
		JLabel lblNewLabel = new JLabel("");
		lblNewLabel.setIcon(new ImageIcon("MainTheme.gif"));
		lblNewLabel.setBounds(0, 0, 945, 675);
		startPage.add(lblNewLabel);
		startContinueGameButton.addActionListener(this);
		startNewGameButton.addActionListener(this);
		
		leaderInit = new JPanel();
		add(leaderInit, "leaderInit");
		leaderInit.setLayout(null);
		
		JLabel lblNewLabel_1 = new JLabel("");
		lblNewLabel_1.setBounds(55, 149, 320, 480);
		lblNewLabel_1.setIcon(new ImageIcon("leader.jpg"));
		leaderInit.add(lblNewLabel_1);
		
		JLabel lblCard_1 = new JLabel("Set Up");
		lblCard_1.setForeground(new Color(0, 255, 127));
		lblCard_1.setBounds(421, 35, 177, 59);
		lblCard_1.setFont(new Font("Viner Hand ITC", Font.PLAIN, 36));
		leaderInit.add(lblCard_1);
		
		JLabel lblLeaderName = new JLabel("Leader Name:");
		lblLeaderName.setForeground(new Color(102, 205, 170));
		lblLeaderName.setVerticalAlignment(SwingConstants.BOTTOM);
		lblLeaderName.setFont(new Font("Andalus", Font.BOLD, 18));
		lblLeaderName.setBounds(481, 192, 142, 27);
		leaderInit.add(lblLeaderName);
		
		leaderName = new JTextField();
		leaderName.setBounds(637, 191, 246, 21);
		leaderInit.add(leaderName);
		leaderName.setColumns(10);
		
		JLabel lblLeaderOccupation = new JLabel("Leader Occupation:");
		lblLeaderOccupation.setForeground(new Color(102, 205, 170));
		lblLeaderOccupation.setVerticalAlignment(SwingConstants.BOTTOM);
		lblLeaderOccupation.setFont(new Font("Andalus", Font.BOLD, 18));
		lblLeaderOccupation.setBounds(481, 280, 181, 27);
		leaderInit.add(lblLeaderOccupation);
		
		occupationGroup = new ButtonGroup();
		soldierButton = new JRadioButton("SOLDIER");
		soldierButton.setBounds(762, 284, 121, 23);
		leaderInit.add(soldierButton);
		
		medicButton = new JRadioButton("MEDIC");
		medicButton.setBounds(762, 327, 121, 23);
		leaderInit.add(medicButton);
		
		rangerButton = new JRadioButton("RANGER");
		rangerButton.setBounds(762, 370, 121, 23);
		leaderInit.add(rangerButton);
		
		cookButton = new JRadioButton("COOK");
		cookButton.setBounds(762, 414, 121, 23);
		leaderInit.add(cookButton);
		
		occupationGroup.add(soldierButton);
		occupationGroup.add(medicButton);
		occupationGroup.add(rangerButton);
		occupationGroup.add(cookButton);
		soldierButton.setSelected(true);
		
		leadersInitContinueButton = new JButton("CONTINUE");
		leadersInitContinueButton.setFont(new Font("Tahoma", Font.PLAIN, 18));
		leadersInitContinueButton.setBounds(626, 500, 214, 88);
		leaderInit.add(leadersInitContinueButton);
		
		JLabel lblBackground = new JLabel("Background");
		lblBackground.setIcon(new ImageIcon("gamepage0.gif"));
		lblBackground.setBounds(0, 0, 945, 675);
		leaderInit.add(lblBackground);
		leadersInitContinueButton.addActionListener(this);
		
		membersInit = new JPanel();
		add(membersInit, "membersInit");
		membersInit.setLayout(null);
		
		JLabel label = new JLabel("Set Up");
		label.setForeground(new Color(186, 85, 211));
		label.setBounds(421, 35, 154, 59);
		label.setFont(new Font("Viner Hand ITC", Font.PLAIN, 36));
		membersInit.add(label);
		
		membersInitContinueButton = new JButton("CONTINUE");
		membersInitContinueButton.setFont(new Font("Tahoma", Font.PLAIN, 18));
		membersInitContinueButton.setBounds(626, 500, 214, 88);
		membersInit.add(membersInitContinueButton);
		membersInitContinueButton.addActionListener(this);
		
		JLabel lblMember = new JLabel("MEMBER #1:");
		lblMember.setVerticalAlignment(SwingConstants.BOTTOM);
		lblMember.setForeground(new Color(147, 112, 219));
		lblMember.setFont(new Font("Vrinda", Font.BOLD, 18));
		lblMember.setBounds(460, 148, 142, 27);
		membersInit.add(lblMember);
		
		JLabel lblMember_1 = new JLabel("MEMBER #2:");
		lblMember_1.setVerticalAlignment(SwingConstants.BOTTOM);
		lblMember_1.setForeground(new Color(148, 0, 211));
		lblMember_1.setFont(new Font("Vrinda", Font.BOLD, 18));
		lblMember_1.setBounds(460, 236, 142, 27);
		membersInit.add(lblMember_1);
		
		JLabel lblMember_2 = new JLabel("MEMBER #3:");
		lblMember_2.setVerticalAlignment(SwingConstants.BOTTOM);
		lblMember_2.setForeground(new Color(147, 112, 219));
		lblMember_2.setFont(new Font("Vrinda", Font.BOLD, 18));
		lblMember_2.setBounds(460, 330, 142, 27);
		membersInit.add(lblMember_2);
		
		JLabel lblMember_3 = new JLabel("MEMBER #4:");
		lblMember_3.setVerticalAlignment(SwingConstants.BOTTOM);
		lblMember_3.setForeground(new Color(147, 112, 219));
		lblMember_3.setFont(new Font("Vrinda", Font.BOLD, 18));
		lblMember_3.setBounds(460, 425, 142, 27);
		membersInit.add(lblMember_3);
		
		Member1Name = new JTextField();
		Member1Name.setColumns(10);
		Member1Name.setBounds(586, 148, 285, 21);
		membersInit.add(Member1Name);
		
		Member2Name = new JTextField();
		Member2Name.setColumns(10);
		Member2Name.setBounds(586, 237, 285, 21);
		membersInit.add(Member2Name);
		
		Member3Name = new JTextField();
		Member3Name.setColumns(10);
		Member3Name.setBounds(586, 331, 285, 21);
		membersInit.add(Member3Name);
		
		Member4Name = new JTextField();
		Member4Name.setColumns(10);
		Member4Name.setBounds(586, 426, 285, 21);
		membersInit.add(Member4Name);
		
		lblBackground_1 = new JLabel("background");
		lblBackground_1.setIcon(new ImageIcon("gamepage0.gif"));
		lblBackground_1.setBounds(0, 0, 945, 675);
		membersInit.add(lblBackground_1);
		
		gameStart = new JPanel();
		add(gameStart, "gameStart");
		gameStart.setLayout(null);
		
		JLabel lblNewLabel_3 = new JLabel("");
		lblNewLabel_3.setIcon(new ImageIcon("OriginalMap.gif"));
		lblNewLabel_3.setBounds(10, 11, 422, 355);
		gameStart.add(lblNewLabel_3);
		
		JLabel lblNewLabel_4 = new JLabel("May 1, 1940");
		lblNewLabel_4.setFont(new Font("Times New Roman", Font.BOLD | Font.ITALIC, 25));
		lblNewLabel_4.setVerticalAlignment(SwingConstants.TOP);
		lblNewLabel_4.setBounds(440, 63, 293, 31);
		gameStart.add(lblNewLabel_4);
		
		JLabel lblNewLabel_5 = new JLabel("Your forces have been badly defeated.");
		lblNewLabel_5.setVerticalAlignment(SwingConstants.TOP);
		lblNewLabel_5.setFont(new Font("Times New Roman", Font.BOLD | Font.ITALIC, 25));
		lblNewLabel_5.setBounds(440, 104, 443, 39);
		gameStart.add(lblNewLabel_5);
		
		JLabel lblYouHaveBeen = new JLabel("You have been captured in a German camp.");
		lblYouHaveBeen.setVerticalAlignment(SwingConstants.TOP);
		lblYouHaveBeen.setFont(new Font("Times New Roman", Font.BOLD | Font.ITALIC, 25));
		lblYouHaveBeen.setBounds(440, 153, 505, 39);
		gameStart.add(lblYouHaveBeen);
		
		JLabel lblCampAfterGreat = new JLabel("After great struggle, you have");
		lblCampAfterGreat.setVerticalAlignment(SwingConstants.TOP);
		lblCampAfterGreat.setFont(new Font("Times New Roman", Font.BOLD | Font.ITALIC, 25));
		lblCampAfterGreat.setBounds(440, 202, 399, 39);
		gameStart.add(lblCampAfterGreat);
		
		JLabel lblSuccessfullySucceededIn = new JLabel("successfully escaped with your fellow soldiers!");
		lblSuccessfullySucceededIn.setVerticalAlignment(SwingConstants.TOP);
		lblSuccessfullySucceededIn.setFont(new Font("Times New Roman", Font.BOLD | Font.ITALIC, 25));
		lblSuccessfullySucceededIn.setBounds(440, 251, 505, 39);
		gameStart.add(lblSuccessfullySucceededIn);
		
		startMessage = new JLabel("Now! Lead your fellow soldiers");
		startMessage.setVerticalAlignment(SwingConstants.TOP);
		startMessage.setFont(new Font("Times New Roman", Font.BOLD | Font.ITALIC, 29));
		startMessage.setBounds(247, 397, 446, 39);
		gameStart.add(startMessage);
		
		JLabel lblBackToTheir = new JLabel("back to their homeland to London!");
		lblBackToTheir.setVerticalAlignment(SwingConstants.TOP);
		lblBackToTheir.setFont(new Font("Times New Roman", Font.BOLD | Font.ITALIC, 29));
		lblBackToTheir.setBounds(230, 452, 446, 39);
		gameStart.add(lblBackToTheir);
		
		gameStartStartButton = new JButton("GAME START");
		gameStartStartButton.setFont(new Font("Andalus", Font.PLAIN, 18));
		gameStartStartButton.setBounds(659, 525, 180, 60);
		gameStart.add(gameStartStartButton);
		
		JLabel lblNewLabel_6 = new JLabel("");
		lblNewLabel_6.setIcon(new ImageIcon("background5.jpg"));

		lblNewLabel_6.setBounds(0, 0, 945, 675);
		gameStart.add(lblNewLabel_6);
		gameStartStartButton.addActionListener(this);
		//ImageIcon icon = new ImageIcon("bremen.gif");
		
		Party.Ration[] rationChoices = Party.Ration.values();
		
		Party.Pace[] paceChoices = Party.Pace.values();
		system.getParty().setPace(Party.Pace.slow);
		system.getParty().setRations(Party.Ration.poor);
		homePage = new JPanel();
		add(homePage, "homePage");
		homePage.setLayout(null);
		//showMinigame();
		
		lblMap = new JLabel("");
		lblMap.setIcon(new ImageIcon("bremen.gif"));
		lblMap.setBounds(57, 97, 453, 344);
		homePage.add(lblMap);
		
		
		DayLeft = new JLabel("Days Left: 100");
		DayLeft.setForeground(Color.ORANGE);
		DayLeft.setFont(new Font("Viner Hand ITC", Font.BOLD, 32));
		DayLeft.setBounds(365, 26, 262, 52);
		homePage.add(DayLeft);
		
		homeCurrentLabel = new JLabel("Current Location : Bremen");
		homeCurrentLabel.setToolTipText("Current Location:\tBremen");
		homeCurrentLabel.setForeground(Color.PINK);
		homeCurrentLabel.setFont(new Font("Andalus", Font.BOLD, 18));
		homeCurrentLabel.setBounds(586, 107, 311, 26);
		homePage.add(homeCurrentLabel);
		
		homeMember1Health = new JLabel("Member1 :");
		homeMember1Health.setVerticalAlignment(SwingConstants.BOTTOM);
		homeMember1Health.setForeground(Color.PINK);
		homeMember1Health.setFont(new Font("Andalus", Font.BOLD, 18));
		homeMember1Health.setBounds(85, 476, 159, 26);
		homePage.add(homeMember1Health);
		
		homeMember2Health = new JLabel("Member1 :");
		homeMember2Health.setVerticalAlignment(SwingConstants.BOTTOM);
		homeMember2Health.setForeground(Color.PINK);
		homeMember2Health.setFont(new Font("Andalus", Font.BOLD, 18));
		homeMember2Health.setBounds(85, 513, 159, 26);
		homePage.add(homeMember2Health);
		
		homeMember3Health = new JLabel("Member1 :");
		homeMember3Health.setVerticalAlignment(SwingConstants.BOTTOM);
		homeMember3Health.setForeground(Color.PINK);
		homeMember3Health.setFont(new Font("Andalus", Font.BOLD, 18));
		homeMember3Health.setBounds(85, 550, 169, 26);
		homePage.add(homeMember3Health);
		
		homeMember4Health = new JLabel("Member1 :");
		homeMember4Health.setVerticalAlignment(SwingConstants.BOTTOM);
		homeMember4Health.setForeground(Color.PINK);
		homeMember4Health.setFont(new Font("Andalus", Font.BOLD, 18));
		homeMember4Health.setBounds(85, 587, 159, 26);
		homePage.add(homeMember4Health);
		
		lblFoodSuply = new JLabel("Food Supply :                  0");
		lblFoodSuply.setForeground(Color.PINK);
		lblFoodSuply.setFont(new Font("Andalus", Font.BOLD, 18));
		lblFoodSuply.setBounds(586, 144, 280, 26);
		homePage.add(lblFoodSuply);
		
		lblWaterSupply = new JLabel("Water Supply :                0");
		lblWaterSupply.setForeground(Color.PINK);
		lblWaterSupply.setFont(new Font("Andalus", Font.BOLD, 18));
		lblWaterSupply.setBounds(586, 180, 280, 26);
		homePage.add(lblWaterSupply);
		
		JLabel lblWeapon = new JLabel("Weapon: None");
		lblWeapon.setForeground(Color.PINK);
		lblWeapon.setFont(new Font("Andalus", Font.BOLD, 18));
		lblWeapon.setBounds(586, 216, 280, 26);
		homePage.add(lblWeapon);
		
		lblAmmo = new JLabel("Ammo : 0");
		lblAmmo.setForeground(new Color(128, 0, 0));
		lblAmmo.setFont(new Font("Andalus", Font.BOLD, 18));
		lblAmmo.setBounds(586, 252, 280, 26);
		homePage.add(lblAmmo);
		
		lblDistance = new JLabel("Distance : 0");
		lblDistance.setForeground(new Color(128, 0, 0));
		lblDistance.setFont(new Font("Andalus", Font.BOLD, 18));
		lblDistance.setBounds(586, 288, 280, 26);
		homePage.add(lblDistance);
		rationCB = new JComboBox(rationChoices);
		rationCB.setFont(new Font("Tahoma", Font.PLAIN, 12));
		rationCB.setBounds(747, 325, 119, 21);
		homePage.add(rationCB);
		paceCB = new JComboBox(paceChoices);
		paceCB.setFont(new Font("Tahoma", Font.PLAIN, 12));
		paceCB.setBounds(747, 367, 119, 21);
		homePage.add(paceCB);
		
		JLabel lblRationRate = new JLabel("Set Ration");
		lblRationRate.setForeground(new Color(128, 0, 0));
		lblRationRate.setFont(new Font("Andalus", Font.BOLD, 18));
		lblRationRate.setBounds(586, 325, 144, 26);
		homePage.add(lblRationRate);
		
		JLabel lblSetPace = new JLabel("Set Pace");
		lblSetPace.setForeground(new Color(128, 0, 0));
		lblSetPace.setFont(new Font("Andalus", Font.BOLD, 18));
		lblSetPace.setBounds(586, 362, 131, 26);
		homePage.add(lblSetPace);
		
		homeMarchButton = new JButton("March");
		homeMarchButton.setFont(new Font("Century Schoolbook", Font.PLAIN, 18));
		homeMarchButton.setBackground(new Color(255, 250, 250));
		homeMarchButton.setBounds(626, 500, 214, 88);
		homePage.add(homeMarchButton);
		homeMarchButton.addActionListener(this);
		
		toShopButton = new JButton("Shop");
		toShopButton.setBounds(586, 409, 120, 23);
		homePage.add(toShopButton);
		toShopButton.addActionListener(this);
		
		healthBar0 = new JProgressBar();
		healthBar0.setStringPainted(true);
		healthBar0.setFont(new Font("Tahoma", Font.PLAIN, 12));
		healthBar0.setForeground(new Color(0, 128, 0));
		healthBar0.setBounds(262, 476, 222, 18);
		healthBar0.setValue(100);
		homePage.add(healthBar0);
		
		healthBar1 = new JProgressBar();
		healthBar1.setFont(new Font("Tahoma", Font.PLAIN, 12));
		healthBar1.setForeground(new Color(0, 128, 0));
		healthBar1.setStringPainted(true);
		healthBar1.setBounds(262, 513, 222, 18);
		healthBar1.setValue(100);
		homePage.add(healthBar1);
		
		healthBar2 = new JProgressBar();
		healthBar2.setFont(new Font("Tahoma", Font.PLAIN, 12));
		healthBar2.setForeground(new Color(0, 128, 0));
		healthBar2.setStringPainted(true);
		healthBar2.setBounds(262, 550, 222, 18);
		healthBar2.setValue(100);
		homePage.add(healthBar2);
		
		healthBar3 = new JProgressBar();
		healthBar3.setFont(new Font("Tahoma", Font.PLAIN, 12));
		healthBar3.setForeground(new Color(0, 128, 0));
		healthBar3.setStringPainted(true);
		healthBar3.setBounds(262, 587, 222, 18);
		healthBar3.setValue(100);
		homePage.add(healthBar3);
		
		homeSaveGameButton = new JButton("Save Game");
		homeSaveGameButton.setBounds(746, 409, 120, 23);
		homePage.add(homeSaveGameButton);
		homeSaveGameButton.addActionListener(this);
		JLabel label_1 = new JLabel("");
		label_1.setIcon(new ImageIcon("gamepage2.gif"));
		label_1.setBounds(0, 0, 945, 675);
		homePage.add(label_1);
		
		shopPage = new JPanel();
		add(shopPage, "shopPage");
		shopPage.setLayout(null);
		
		JLabel lblNewLabel_7 = new JLabel("SHOP");
		lblNewLabel_7.setForeground(Color.WHITE);
		lblNewLabel_7.setFont(new Font("Vrinda", Font.BOLD, 36));
		lblNewLabel_7.setBounds(356, 49, 108, 72);
		shopPage.add(lblNewLabel_7);
		
		JLabel lblFood = new JLabel("Food($1/1Food)");
		lblFood.setForeground(Color.WHITE);
		lblFood.setFont(new Font("Vrinda", Font.PLAIN, 26));
		lblFood.setBounds(142, 300, 221, 32);
		shopPage.add(lblFood);
		
		JLabel lblWater = new JLabel("Water($1/1Water)");
		lblWater.setForeground(Color.WHITE);
		lblWater.setFont(new Font("Vrinda", Font.PLAIN, 26));
		lblWater.setBounds(142, 344, 221, 32);
		shopPage.add(lblWater);
		
		JLabel lblWeapon_1 = new JLabel("Weapon");
		lblWeapon_1.setForeground(Color.WHITE);
		lblWeapon_1.setFont(new Font("Vrinda", Font.PLAIN, 26));
		lblWeapon_1.setBounds(142, 388, 156, 32);
		shopPage.add(lblWeapon_1);
		
		JLabel lblAmmunition = new JLabel("Ammunition($1)");
		lblAmmunition.setForeground(Color.WHITE);
		lblAmmunition.setFont(new Font("Vrinda", Font.PLAIN, 26));
		lblAmmunition.setBounds(142, 432, 221, 32);
		shopPage.add(lblAmmunition);
		
		//Current item display
		JLabel currentFood = new JLabel("Currently have: "+system.getParty().getFood());
		currentFood.setForeground(Color.WHITE);
		currentFood.setLocation(51, 0);
		JLabel currentWater = new JLabel("Currently have: "+system.getParty().getWater());
		currentWater.setForeground(Color.WHITE);
		currentWater.setLocation(51, 0);
		JLabel currentAmmo = new JLabel("Currently have: "+system.getParty().getAmmunition());
		currentAmmo.setForeground(Color.WHITE);
		currentAmmo.setLocation(51, 0);
		JLabel currentMoney = new JLabel("Currently have: "+system.getParty().getMoney());
		currentMoney.setForeground(Color.WHITE);
		currentMoney.setLocation(51, 0);
		String currentInventoryString = new String("Current inventory: ");
		boolean first = true;
		for(Item currentOne:system.getParty().getInventory()){
			if(!first)
				currentInventoryString+=", ";
			else
				first = false;
			currentInventoryString+=currentOne.toString();
		}
		JLabel currentInventory = new JLabel(currentInventoryString);
		currentInventory.setForeground(Color.WHITE);
		currentInventory.setLocation(51, 0);
		shopPage.add(currentFood);
		shopPage.add(currentWater);
		shopPage.add(currentAmmo);
		shopPage.add(currentMoney);
		shopPage.add(currentInventory);
		//End current item display
		
		shopFoodText = new JTextField();
		shopFoodText.setForeground(Color.BLACK);
		shopFoodText.setBounds(375, 310, 116, 21);
		shopPage.add(shopFoodText);
		shopFoodText.setColumns(10);
		
		shopWaterText = new JTextField();
		shopWaterText.setForeground(Color.BLACK);
		shopWaterText.setBounds(375, 354, 116, 21);
		shopPage.add(shopWaterText);
		shopWaterText.setColumns(10);
		
		shopAmmunitionText = new JTextField();
		shopAmmunitionText.setForeground(Color.BLACK);
		shopAmmunitionText.setBounds(375, 442, 116, 21);
		shopPage.add(shopAmmunitionText);
		shopAmmunitionText.setColumns(10);
		
		Party.Weapon[] weaponChoices = Party.Weapon.values();
		shopWeaponCB = new JComboBox(weaponChoices);
		shopWeaponCB.setForeground(Color.BLACK);
		shopWeaponCB.setBounds(375, 388, 116, 30);
		shopPage.add(shopWeaponCB);
		
		shopBuyButton = new JButton("BUY");
		shopBuyButton.setForeground(Color.BLACK);
		shopBuyButton.setBounds(539, 575, 97, 23);
		shopPage.add(shopBuyButton);
		shopBuyButton.addActionListener(this);
		
		shopBackButton = new JButton("BACK");
		shopBackButton.setForeground(Color.BLACK);
		shopBackButton.setBounds(157, 575, 97, 23);
		shopPage.add(shopBackButton);
		
		JLabel Others = new JLabel("Others Items");
		Others.setForeground(Color.WHITE);
		Others.setToolTipText("");
		Others.setFont(new Font("Dialog", Font.PLAIN, 26));
		Others.setBounds(142, 476, 221, 32);
		shopPage.add(Others);
		
		ArrayList<Item> itemList = system.getShop().getItemList();
		Object[] itemListArr = itemList.toArray();
		shopItemCB = new JComboBox(itemListArr);
		shopItemCB.setForeground(Color.BLACK);
		shopItemCB.setBounds(375, 476, 116, 30);
		shopPage.add(shopItemCB);
		
		shopMoneyLabel = new JLabel("Current Money:");
		shopMoneyLabel.setForeground(Color.WHITE);
		shopMoneyLabel.setFont(new Font("Dialog", Font.PLAIN, 26));
		shopMoneyLabel.setBounds(142, 121, 403, 32);
		shopPage.add(shopMoneyLabel);
		
		shopWeaponLabel = new JLabel("Current Weapon:");
		shopWeaponLabel.setForeground(Color.WHITE);
		shopWeaponLabel.setFont(new Font("Dialog", Font.PLAIN, 26));
		shopWeaponLabel.setBounds(142, 165, 403, 32);
		shopPage.add(shopWeaponLabel);
		
		shopFoodLabel = new JLabel("Current Food:");
		shopFoodLabel.setForeground(Color.WHITE);
		shopFoodLabel.setFont(new Font("Dialog", Font.PLAIN, 26));
		shopFoodLabel.setBounds(557, 121, 403, 32);
		shopPage.add(shopFoodLabel);
		
		shopWaterLabel = new JLabel("Current Water:");
		shopWaterLabel.setForeground(Color.WHITE);
		shopWaterLabel.setFont(new Font("Dialog", Font.PLAIN, 26));
		shopWaterLabel.setBounds(557, 165, 403, 32);
		shopPage.add(shopWaterLabel);
		
		shopAmmunitionLabel = new JLabel("Current Ammunition:");
		shopAmmunitionLabel.setForeground(Color.WHITE);
		shopAmmunitionLabel.setFont(new Font("Dialog", Font.PLAIN, 26));
		shopAmmunitionLabel.setBounds(557, 209, 403, 32);
		shopPage.add(shopAmmunitionLabel);
		
		shopWeightLabel = new JLabel("Current Weight:");
		shopWeightLabel.setForeground(Color.WHITE);
		shopWeightLabel.setFont(new Font("Dialog", Font.PLAIN, 26));
		shopWeightLabel.setBounds(142, 209, 403, 32);
		shopPage.add(shopWeightLabel);
		
		shopItemsLabel = new JLabel("Current Items: (none)");
		shopItemsLabel.setForeground(Color.WHITE);
		shopItemsLabel.setFont(new Font("Dialog", Font.PLAIN, 15));
		shopItemsLabel.setBounds(142, 253, 818, 32);
		shopPage.add(shopItemsLabel);
		
		lblNewLabel_13 = new JLabel("knife: $3    k1: $5   m16: $25   ak47: $50");
		lblNewLabel_13.setForeground(Color.WHITE);
		lblNewLabel_13.setBounds(620, 313, 221, 16);
		shopPage.add(lblNewLabel_13);
		
		lblBinoculars = new JLabel("Each Items: $10 & 10Weight");
		lblBinoculars.setForeground(Color.WHITE);
		lblBinoculars.setBounds(620, 357, 221, 16);
		shopPage.add(lblBinoculars);
		
		JLabel lblNewLabel_2 = new JLabel("New label");
		lblNewLabel_2.setBounds(0, 0, 945, 675);
		lblNewLabel_2.setIcon(new ImageIcon("shopBG.jpg"));
		shopPage.add(lblNewLabel_2);
		shopBackButton.addActionListener(this);
		
		victoryPanel = new JPanel();
		add(victoryPanel, "victoryPage");
		victoryPanel.setLayout(null);
		
		JLabel lblVictory = new JLabel("Victory");
		lblVictory.setFont(new Font("Lucida Grande", Font.PLAIN, 40));
		lblVictory.setBounds(268, 65, 161, 80);
		victoryPanel.add(lblVictory);
		
		riverPanel = new JPanel();
		add(riverPanel, "riverPage");
		victoryPanel.setLayout(null);
		
		JLabel lblRiver = new JLabel("River");
		lblRiver.setFont(new Font("Lucida Grande", Font.PLAIN, 40));
		lblRiver.setBounds(268, 65, 161, 80);
		riverPanel.add(lblRiver);
		
		cross = new JButton("Swim");
		cross.addActionListener(this);
		boat = new JButton("Buy a boat");
		boat.addActionListener(this);
		around = new JButton("Walk around");
		around.addActionListener(this);
		JLabel lblNewLabel_12 = new JLabel("");
		lblNewLabel_12.setIcon(new ImageIcon("river.jpg"));
		lblNewLabel_12.setBounds(174, 139, 415, 411);
		riverPanel.add(lblNewLabel_12);
		riverPanel.add(cross);
		riverPanel.add(boat);
		riverPanel.add(around);
		victoryCreditsButton = new JButton("Credits");
		victoryCreditsButton.setBounds(519, 562, 117, 29);
		victoryPanel.add(victoryCreditsButton);
		victoryCreditsButton.addActionListener(this);
		
		creditsPanel = new JPanel();
		add(creditsPanel, "creditsPanel");
		creditsPanel.setLayout(null);
		
		lblNewLabel_10 = new JLabel("AUTHOR:");
		lblNewLabel_10.setFont(new Font("Lucida Grande", Font.PLAIN, 40));
		lblNewLabel_10.setBounds(282, 6, 195, 91);
		creditsPanel.add(lblNewLabel_10);
		
		lblNewLabel_11 = new JLabel("New label");
		lblNewLabel_11.setIcon(new ImageIcon("robert.jpg"));
		lblNewLabel_11.setBounds(23, 100, 668, 508);
		creditsPanel.add(lblNewLabel_11);
		
		lblThanksForPlaying = new JLabel("Thanks for Playing!");
		lblThanksForPlaying.setFont(new Font("Lucida Grande", Font.PLAIN, 16));
		lblThanksForPlaying.setBounds(250, 642, 247, 56);
		creditsPanel.add(lblThanksForPlaying);
		
		panel = new JPanel();
		add(panel, "name_1320452979629361000");
		panel.setLayout(null);
		
		saveTitle = new JLabel("Save Game");
		saveTitle.setFont(new Font("Lucida Grande", Font.PLAIN, 40));
		saveTitle.setBounds(299, 45, 233, 92);
		panel.add(saveTitle);
		
		lblNewLabel_8 = new JLabel("New label");
		lblNewLabel_8.setBounds(112, 263, 61, 16);
		panel.add(lblNewLabel_8);

		diedPanel = new JPanel();
		add(diedPanel, "diedPanel");
		diedPanel.setLayout(null);
		
		diedMessageText = new JLabel("is  T.T;");
		diedMessageText.setFont(new Font("Lucida Grande", Font.PLAIN, 36));
		diedMessageText.setBounds(40, 190, 691, 70);
		diedPanel.add(diedMessageText);
		
		diedOkayButton = new JButton("OKAY");
		diedOkayButton.setBounds(297, 491, 117, 29);
		diedOkayButton.addActionListener(this);
		diedPanel.add(diedOkayButton);
		
		endPanel = new JPanel();
		add(endPanel, "endPanel");
		endPanel.setLayout(null);
		
		lblEverybodyIs = new JLabel("Everybody is dead!");
		lblEverybodyIs.setBounds(264, 5, 221, 30);
		lblEverybodyIs.setFont(new Font("Lucida Grande", Font.PLAIN, 24));
		endPanel.add(lblEverybodyIs);
		
		JLabel lblNewLabel_9 = new JLabel("GAME OVER");
		lblNewLabel_9.setBounds(341, 184, 144, 16);
		endPanel.add(lblNewLabel_9);
		
		btnPlayAgain = new JButton("PLAY AGAIN");
		btnPlayAgain.setBounds(289, 589, 117, 29);
		endPanel.add(btnPlayAgain);
		btnPlayAgain.addActionListener(this);
		
		//minigamePanel = new JPanel();
		//add(minigamePanel, "minigamePanel");
		//minigamePanel.setLayout(null);
		
		eventPanel = new JPanel();
		eventPanel.setLayout(new BoxLayout(eventPanel, BoxLayout.Y_AXIS));
		add(eventPanel, "eventPanel");
		
		lblMap.setIcon(new ImageIcon("bremen.gif"));
		

		DayLeft.setText("Days Left: " + system.getDaysLeft());
		lblFoodSuply.setText("Food Supply: "+system.getParty().getFood());
		lblWaterSupply.setText("Water Supply: "+system.getParty().getWater());
		lblDistance.setText("Distance: "+system.getParty().getDistance());
		system.getParty().setRations((Party.Ration)rationCB.getSelectedItem());
		system.getParty().setPace((Party.Pace)paceCB.getSelectedItem());
	}
	
	public void showRandomEventPanel(RandomEvent r)
	{
		eventPanel.removeAll();
		JLabel mainLabel= new JLabel(r.getDisplayName());
		mainLabel.setFont(new Font("Lucida Grande", Font.PLAIN, 40));
		mainLabel.setBounds(268, 65, 161, 80);
		eventPanel.add(mainLabel);
	
		JLabel lbl = new JLabel("");
		lbl.setIcon(new ImageIcon(r.getImageFilename()));
		lbl.setBounds(174, 139, 415, 411);
		eventPanel.add(lbl);
		
		JButton[] options = r.getResponseElements();
		JPanel buttPan = new JPanel();
		buttPan.setLayout(new BoxLayout(buttPan, BoxLayout.X_AXIS));
		for (int i=0; i<options.length; i++)
			buttPan.add(options[i]);
		eventPanel.add(buttPan);
		cards.show(this, "eventPanel");
	}
	
	public void userRespondedToRandomEvent()
	{
		cards.show(this, "homePage");
	}
	
	public void passDay() {
		
	}
	
	public void updateHealth(){
		homeMember1Health.setText(system.getParty().getTravellers().get(0) + " Health:");
		homeMember2Health.setText(system.getParty().getTravellers().get(1) + " Health:");
		homeMember3Health.setText(system.getParty().getTravellers().get(2) + " Health:");
		homeMember4Health.setText(system.getParty().getTravellers().get(3) + " Health:");
		healthBar0.setValue(system.getParty().getTravellers().get(0).getHealth());
		if (system.getParty().getTravellers().get(0).getAlive() == false && system.getParty().getTravellers().get(0).getPrinted() == false) {
			diedMessageText.setText(system.getParty().getTravellers().get(0).getName() + ", " + diedMessageText.getText());
			JOptionPane.showMessageDialog(null, system.getParty().getTravellers().get(0).getName() + " died");
			system.getParty().getTravellers().get(0).setPrinted(true);
		}
		
		healthBar1.setValue(system.getParty().getTravellers().get(1).getHealth());
		if (system.getParty().getTravellers().get(1).getAlive() == false && system.getParty().getTravellers().get(1).getPrinted() == false) {
			diedMessageText.setText(system.getParty().getTravellers().get(1).getName() + ", " + diedMessageText.getText());
			JOptionPane.showMessageDialog(null, system.getParty().getTravellers().get(1).getName() + " died");
			system.getParty().getTravellers().get(1).setPrinted(true);
		}
		

		healthBar2.setValue(system.getParty().getTravellers().get(2).getHealth());
		if (system.getParty().getTravellers().get(2).getAlive() == false && system.getParty().getTravellers().get(2).getPrinted() == false) {
			diedMessageText.setText(system.getParty().getTravellers().get(2).getName() + ", " + diedMessageText.getText());
			JOptionPane.showMessageDialog(null, system.getParty().getTravellers().get(2).getName() + " died");
			system.getParty().getTravellers().get(2).setPrinted(true);
		}
		
		healthBar3.setValue(system.getParty().getTravellers().get(3).getHealth());
		if (system.getParty().getTravellers().get(3).getAlive() == false && system.getParty().getTravellers().get(3).getPrinted() == false) {
			diedMessageText.setText(system.getParty().getTravellers().get(3).getName() + ", " + diedMessageText.getText());
			JOptionPane.showMessageDialog(null, system.getParty().getTravellers().get(3).getName() + " died");
			system.getParty().getTravellers().get(3).setPrinted(true);
		}
	}
	
	public void updateMap(){
		if (system.getParty().getCurrent().getName().equals("Bremen")||system.getParty().getCurrent().getName().equals("Field of Bremen")){
			lblMap.setIcon(new ImageIcon("bremen.gif"));
		}
		if (system.getParty().getCurrent().getName().equals("Oldenburg")||system.getParty().getCurrent().getName().equals("The Dark Forest")){
			lblMap.setIcon(new ImageIcon("oldenburg.gif"));
		}
		if (system.getParty().getCurrent().getName().equals("Apeldoorm")||system.getParty().getCurrent().getName().equals("Holland")){
			lblMap.setIcon(new ImageIcon("apeldoorm.gif"));
		}
		if (system.getParty().getCurrent().getName().equals("Eindhoven")||system.getParty().getCurrent().getName().equals("Belgique Capital")){
			lblMap.setIcon(new ImageIcon("eindhoven.gif"));
		}
		if (system.getParty().getCurrent().getName().equals("Bruxelles")||system.getParty().getCurrent().getName().equals("Battlefield of France")){
			lblMap.setIcon(new ImageIcon("bruxelles.gif"));
		}
		if (system.getParty().getCurrent().getName().equals("Reims")||system.getParty().getCurrent().getName().equals("The Impossible Road")){
			lblMap.setIcon(new ImageIcon("reims.gif"));
		}
		if (system.getParty().getCurrent().getName().equals("Paris")||system.getParty().getCurrent().getName().equals("To the shore")){
			lblMap.setIcon(new ImageIcon("paris.gif"));
		}
		if (system.getParty().getCurrent().getName().equals("Amiens")||system.getParty().getCurrent().getName().equals("Last Push")){
			lblMap.setIcon(new ImageIcon("Amiens.gif"));
		}
		if (system.getParty().getCurrent().getName().equals("Lille")) {
			lblMap.setIcon(new ImageIcon("lille.gif"));
			homeCurrentLabel.setText("Current Location: " + system.getParty().getCurrent().getName());
			cards.show(this, "victoryPage");
		}
	}
	
	/**
	 * Represents the action performed as a user input
	 */
	public void actionPerformed(ActionEvent e) {
		if (e.getSource() == skipButton) {
			system.getParty().getLeader().setName("Sam");
			system.getParty().getLeader().setOccupation(Occupation.SOLDIER);
			
			system.getParty().addTraveller(new Member("Andrew"));
			system.getParty().addTraveller(new Member("Hyangjin"));
			system.getParty().addTraveller(new Member("Jeff"));
			system.getParty().addTraveller(new Member("Robert"));
			updateHealth();
			
			cards.show(this, "homePage");
		}
		else if (e.getSource() == startNewGameButton) {
			cards.show(this, "leaderInit");
		}
		else if (e.getSource() == leadersInitContinueButton && leaderName.getText().length() != 0) {
			system.getParty().getLeader().setName(leaderName.getText());
			cards.show(this, "membersInit");
			
			if (soldierButton.isSelected())
				system.getParty().getLeader().setOccupation(Occupation.SOLDIER);
			else if (medicButton.isSelected())
				system.getParty().getLeader().setOccupation(Occupation.MEDIC);
			else if (rangerButton.isSelected())
				system.getParty().getLeader().setOccupation(Occupation.RANGER);
			else if (cookButton.isSelected())
				system.getParty().getLeader().setOccupation(Occupation.COOK);
			startMessage.setText(leaderName.getText() + "! Lead your fellow soldiers");
			
		}
		else if (e.getSource() == membersInitContinueButton && Member1Name.getText().length() != 0 &&
				Member2Name.getText().length() != 0 && Member3Name.getText().length() != 0 && 
				Member4Name.getText().length() != 0) {
			system.getParty().getTravellers().clear();
			system.getParty().addTraveller(new Member(Member1Name.getText()));
			system.getParty().addTraveller(new Member(Member2Name.getText()));
			system.getParty().addTraveller(new Member(Member3Name.getText()));
			system.getParty().addTraveller(new Member(Member4Name.getText()));
			
			updateHealth();
			
			cards.show(this, "gameStart");
		}
		else if (e.getSource() == gameStartStartButton) {
			cards.show(this, "homePage");
			if(system.getParty().getLeader().getOccupation().equals(Occupation.COOK))
				JOptionPane.showMessageDialog(null, "Because "+system.getParty().getLeader().getName()+" is a cook, the party will consume less ration.");
			else if(system.getParty().getLeader().getOccupation().equals(Occupation.RANGER))
					JOptionPane.showMessageDialog(null, "Because "+system.getParty().getLeader().getName()+" is a ranger, every detour will take less days.");
			else if(system.getParty().getLeader().getOccupation().equals(Occupation.MEDIC))
					JOptionPane.showMessageDialog(null, "Because "+system.getParty().getLeader().getName()+" is a medic, the party members are less likely to die.");
			else if(system.getParty().getLeader().getOccupation().equals(Occupation.SOLDIER))
			{
				system.getParty().setCapacity(300);
				JOptionPane.showMessageDialog(null, "Because "+system.getParty().getLeader().getName()+" is a soldier, the party can carry more weight.");
			}
		}
		else if (e.getSource() == homeMarchButton) {
			try {
				Thread.sleep(0);
			} catch (InterruptedException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
			
			
			system.decDay();
			system.getParty().setRations((Party.Ration)rationCB.getSelectedItem());
			system.getParty().setPace((Party.Pace)paceCB.getSelectedItem());
			system.getParty().day();
			DayLeft.setText("Days Left: " + system.getDaysLeft());
			lblFoodSuply.setText("Food Supply: "+system.getParty().getFood());
			lblWaterSupply.setText("Water Supply: "+system.getParty().getWater());
			lblDistance.setText("Distance: "+system.getParty().getDistance());
			system.getParty().setRations((Party.Ration)rationCB.getSelectedItem());
			system.getParty().setPace((Party.Pace)paceCB.getSelectedItem());
			
			updateMap();
			updateHealth();
			
			if (system.getParty().getCurrent().hasWater==true)
			{
				cards.show(this, "riverPage");
			}
			else {
				homeCurrentLabel.setText("Current Location: " + system.getParty().getCurrent().getName());
			}
			
			
			boolean all = true;
			for (int i=0; i<system.getParty().getTravellers().size(); i++) {
				if (system.getParty().getTravellers().get(i).getAlive() == true)
					all = false;
			}
			if (all || system.getLose() == true) {
				cards.show(this, "endPanel");
			}
			if (system.getParty().getNoSupply()) {
				rationCB.setSelectedItem(Party.Ration.none);
			}
			
		}
		else if (e.getSource() == toShopButton) {
			if (system.getParty().getCurrent() instanceof City) {
				shopMoneyLabel.setText("Current Money: " + system.getParty().getMoney());
				shopWeaponLabel.setText("Current Weapon: " + system.getParty().getWeapon());
				shopWeightLabel.setText("Current Weight: " + system.getParty().getWeight());
				shopFoodLabel.setText("Current Food: " + system.getParty().getFood());
				shopWaterLabel.setText("Current Water: " + system.getParty().getWater());
				shopAmmunitionLabel.setText("Current Ammunition: " + system.getParty().getAmmunition());
				if (system.getParty().getInventory().isEmpty()) {
					shopItemsLabel.setText("Current Items: (none)");
				}
				else {
					shopItemsLabel.setText("Current Items: ");
					for (int i=0; i<system.getParty().getInventory().size(); i++) {
						shopItemsLabel.setText(shopItemsLabel.getText() + system.getParty().getInventory().get(i));
					}
				}
				cards.show(this, "shopPage");
			}
		}
		else if (e.getSource() == shopBackButton) {
			cards.show(this, "homePage");
			DayLeft.setText("Days Left: " + system.getDaysLeft());
			lblFoodSuply.setText("Food Supply: "+system.getParty().getFood());
			lblWaterSupply.setText("Water Supply: "+system.getParty().getWater());
			lblDistance.setText("Distance: "+system.getParty().getDistance());
			lblAmmo.setText("Ammo: "+system.getParty().getAmmunition());
		}
		
		// ----------------------Shop---------------------------------------------------------------
		else if (e.getSource() == shopBuyButton) {
			
			int moneySpent=0, weightSpent=0;
			String foodAmount = shopFoodText.getText();
			String waterAmount = shopWaterText.getText();
			String ammunitionAmount = shopAmmunitionText.getText();
			
			int foodChange = 0;
			int waterChange = 0;
			int ammunitionChange = 0;
			int itemChange = 0;
			int weaponChange = 0;
			
			if (foodAmount.length() > 0) {	
				try {
					foodChange = Integer.parseInt(foodAmount);
				}
				catch (Exception exc) {
					JOptionPane.showMessageDialog(null, "Please insert a number");
				}
			}
			if (waterAmount.length() > 0) {
				try {
					waterChange = Integer.parseInt(waterAmount);
				}
				catch (Exception exc) {
					JOptionPane.showMessageDialog(null, "Please insert a number");
				}
			}
			if (ammunitionAmount.length() > 0) {
				try {
					ammunitionChange = Integer.parseInt(ammunitionAmount);
				}
				catch (Exception exc) {
					JOptionPane.showMessageDialog(null, "Please insert a number");
				}
			}
			
			if (!shopItemCB.getSelectedItem().toString().equals("none")) {
				itemChange = 10;
			}
			
			if (shopWeaponCB.getSelectedItem().equals(Party.Weapon.ak47)) {
				if (!system.getParty().getWeapon().equals(Party.Weapon.ak47))
					weaponChange = 50;
			}
			else if (shopWeaponCB.getSelectedItem().equals(Party.Weapon.m16)) {
				if (!system.getParty().getWeapon().equals(Party.Weapon.m16))
					weaponChange = 25;
			}
			else if (shopWeaponCB.getSelectedItem().equals(Party.Weapon.k1)) {
				if (!system.getParty().getWeapon().equals(Party.Weapon.k1))
					weaponChange = 5;
			}
			else if (shopWeaponCB.getSelectedItem().equals(Party.Weapon.knife)) {
				if (!system.getParty().getWeapon().equals(Party.Weapon.knife))
					weaponChange = 3;
			}
			if(system.getParty().getInventory().contains((Item)shopItemCB.getSelectedItem()))
			{
				itemChange = 0;
			}
			moneySpent = foodChange + waterChange + ammunitionChange + itemChange + weaponChange; // for now assume each item cost 1
			weightSpent = foodChange + waterChange + ammunitionChange + itemChange; // for now assume weight is 1 for all
			
			
			boolean enoughMoney = system.getParty().updateMoney(-moneySpent);
			boolean enoughWeight = system.getParty().updateWeight(weightSpent);
			if(!enoughMoney||!enoughWeight)
			{
				system.getParty().updateMoney(+moneySpent);
				system.getParty().updateWeight(-weightSpent);
			}
			if (enoughMoney && enoughWeight) {
				system.getShop().buyFood(foodChange);	
				system.getShop().buyWater(waterChange);
				system.getShop().buyAmmunition(ammunitionChange);
				if(!shopItemCB.getSelectedItem().toString().equals("none"))
					system.getParty().addToInventory((Item)shopItemCB.getSelectedItem());
				if(!shopWeaponCB.getSelectedItem().equals("none"))
					system.getParty().setWeapon((Party.Weapon)shopWeaponCB.getSelectedItem());
			}	// logic error: if only one of money or weight illegal, there is problem... leave it for now
			else {
				JOptionPane.showMessageDialog(null, "Not enough money or exceed maximum weight capacity. The maximum capacity is "+system.getParty().getCapacity()+".");
			}
			
			shopMoneyLabel.setText("Current Money: " + system.getParty().getMoney());
			shopWeaponLabel.setText("Current Weapon: " + system.getParty().getWeapon());
			shopWeightLabel.setText("Current Weight: " + system.getParty().getWeight());
			shopFoodLabel.setText("Current Food: " + system.getParty().getFood());
			shopWaterLabel.setText("Current Water: " + system.getParty().getWater());
			shopAmmunitionLabel.setText("Current Ammunition: " + system.getParty().getAmmunition());
			if (system.getParty().getInventory().isEmpty()) {
				shopItemsLabel.setText("Current Items: (none)");
			}
			else {
				shopItemsLabel.setText("Current Items: ");
				for (int i=0; i<system.getParty().getInventory().size(); i++) {
					shopItemsLabel.setText(shopItemsLabel.getText() + system.getParty().getInventory().get(i) + "/");
				}
			}
		}
		
		//---------------------Shop-----------------------------------------------------------------------------
		else if (e.getSource() == victoryCreditsButton) {
			cards.show(this,  "creditsPanel");
		}
		else if (e.getSource() == cross){
			if(Math.random()>0.5)
			{
				Random gen = new Random();
				int i = gen.nextInt(4);
				if(system.getParty().getTravellers().get(i).getAlive()==true)
				{
					system.getParty().killPlayer(i);
					JOptionPane.showMessageDialog(null, system.getParty().getTravellers().get(i)+" has drowned.");
				}
				updateHealth();
			}
			system.getParty().setCurrent(system.getParty().getCurrent().getNext());
			cards.show(this, "homePage");
		}
		else if(e.getSource() == boat){
			if(system.getParty().getMoney()>=10)
			{
				system.getParty().setMoney(system.getParty().getMoney()-10);
				system.getParty().setCurrent(system.getParty().getCurrent().getNext());
			}
			else
			{
				system.decDay();
				system.decDay();
				system.decDay();
				system.getParty().setCurrent(system.getParty().getCurrent().getNext());
			}
			cards.show(this, "homePage");
		}
		else if(e.getSource() == around){
			system.decDay();
			system.decDay();
			system.decDay();
			system.getParty().setCurrent(system.getParty().getCurrent().getNext());
			cards.show(this, "homePage");
		}
		else if (e.getSource() == diedOkayButton) {
			cards.show(this, "homePage");
		}
		else if (e.getSource() == this.homeSaveGameButton)
		{
			system.saveGame();
			JOptionPane.showMessageDialog(null, "Saved!");
		}
		else if (e.getSource() == this.btnPlayAgain) {
			system = new GameSystem();
			cards.show(this, "homePage");
			cards.show(this, "startPage");
		}
		else if(e.getSource() == this.startContinueGameButton)
		{
			system.loadGame();
			DayLeft.setText("Days Left: " + system.getDaysLeft());
			lblFoodSuply.setText("Food Supply: "+system.getParty().getFood());
			lblWaterSupply.setText("Water Supply: "+system.getParty().getWater());
			lblDistance.setText("Distance: "+system.getParty().getDistance());
			system.getParty().setRations((Party.Ration)rationCB.getSelectedItem());
			system.getParty().setPace((Party.Pace)paceCB.getSelectedItem());
			homeCurrentLabel.setText("Current Location : "+system.getParty().getCurrent());
			updateMap();
			updateHealth();
			system.setLose(false);
			cards.show(this, "homePage");
		}
	}
	
	public int getWidth(){
		return width;
	}
	public int getHeight(){
		return height;
	}

	public void showMinigame() {
		minigamePanel.removeAll();
		JPanel playWindow = new MgBoard(width, height, system.getParty(),this);
		this.minigamePanel.add(playWindow);
		cards.show(this, "minigamePanel");
		playWindow.requestFocus();
	}
	
}
